/** 
 * @Description: 文件描述
 * @Author: 程前
 * @Date: 2025-02-10 10:59:27
 * @LastEditors: 程前
 * @LastEditTime: 2025-02-17 16:01:37
 */

import { Viewer, Entity, ScreenSpaceEventHandler } from "cesium";
import BaseLoader from "../base"
import { ICesiumLoader } from "@/types/loader";
import { useCesiumGlobalStore } from "@/store/modules/cesiun-global"
import { CylinderBeam, CircleBeam, SimRadar, Sea } from "@/cesium/test";

export default class Test extends BaseLoader implements ICesiumLoader {
    viewer: Viewer;
    entity: Entity;
    loader: CylinderBeam | CircleBeam | SimRadar | Sea;
    type: string;
    handler: ScreenSpaceEventHandler | null = null
    constructor(viewer: Viewer, type: string) {
        super(viewer);
        this.viewer = viewer;
        this.type = type
        this.handler = new ScreenSpaceEventHandler(this.viewer.scene.canvas);
        this.init(viewer, this.handler);
    }

    init(viewer: Viewer, handler: ScreenSpaceEventHandler): void {
        switch (this.type) {
            case 'cylinderBeam':
                this.loader = new CylinderBeam(viewer, handler);
                break;
            case 'circleBeam':
                this.loader = new CircleBeam(viewer, handler);
                break
            case 'simradar':
                this.loader = new SimRadar(viewer, handler);
                break
            case 'sea':
                this.loader = new Sea(viewer)
                break;
            default:
                break;
        }
        this.loader.initEvents()
    }


    getData(): Record<string, any> {
        throw new Error('Method not implemented.');
    }

    getEntity(): Entity | void {
        throw new Error('Method not implemented.');
    }

    remove(): boolean {
        throw new Error('Method not implemented.');
    }

    destroy(): void {
        this.loader.destroy()
        super.removeEscEvent()
        useCesiumGlobalStore().loader = null
    }
}